﻿using Bettzueche.RLLibrary.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bettzueche.RLLibrary.Functions
{
    public abstract class AbstractEligibilityFunction
    {
        protected double[] Eligibilities;

        public abstract double[] this[IState state, IAction action] { get; set; }

        double _minE;
        /// <summary>
        /// Falls <c>EFunction</c> genutzt wird, gibt <c>MinE</c> den kleinsten Wert für
        /// 'eligibility' an, der nicht zu 0.0 interpretiert wird.
        /// </summary>
        /// <value>
        /// Der minimale Verantwortlichkeitsfaktor e. Negative Werte werden auf 0.0 gesetzt.
        /// </value>
        public virtual double MinE {
            get { return _minE; }
            set { _minE = Math.Max(0.0, value); }
        }

        public AbstractEligibilityFunction(int size) {
            Eligibilities = new double[size];
        }

        public abstract void Clear();
    }

    public abstract class AbstractEligibilityFunction<S, A> : AbstractEligibilityFunction
        where S : IState
        where A : IAction
    {
        public abstract double[] this[S state, A action] { get; set; }

        public AbstractEligibilityFunction(int size)
            : base(size) {

        }
    }
}
